<template>
    <div>
        <button @click="getTalk">获取土味情话</button>
        <ul>
            <li v-for="item in talkList" :key="item.id">
                {{ item.title }}
            </li>
        </ul>
    </div>
</template>

<script lang="ts" setup name="LoveTalk">
import {useTalkStore} from "@/store/loveTalk";
import {storeToRefs} from "pinia";

let useTalk = useTalkStore()
let {talkList} = storeToRefs(useTalk)

useTalk.$subscribe((mutation, state)=> {
    localStorage.setItem('talkList',JSON.stringify(state.talkList))
})

async function getTalk() {
    useTalk.getATalk()
}
</script>

<style scoped>

</style>
